// 测试"一键报名"按钮的禁用逻辑

// 模拟岗位数据
const mockJobData = [
	{
		id: '1',
		title: '普工',
		salary: '18元/小时',
		location: '深圳某工厂',
		signup: false, // 未报名
	},
	{
		id: '2',
		title: '技术员',
		salary: '25元/小时',
		location: '东莞某工厂',
		signup: true, // 已报名
	},
	{
		id: '3',
		title: '质检员',
		salary: '20元/小时',
		location: '惠州某工厂',
		signup: null, // 未定义
	}
]

// 测试按钮状态逻辑
function testButtonState() {
	console.log('=== 测试"一键报名"按钮状态 ===')
	
	mockJobData.forEach((job, index) => {
		const buttonText = job.signup ? '已报名' : '一键报名'
		const isDisabled = job.signup === true
		const canClick = !isDisabled
		
		console.log(`岗位${index + 1}: ${job.title}`)
		console.log(`  signup字段: ${job.signup}`)
		console.log(`  按钮文字: ${buttonText}`)
		console.log(`  是否禁用: ${isDisabled}`)
		console.log(`  是否可点击: ${canClick}`)
		console.log('---')
	})
}

// 测试按钮点击事件
function testButtonClick() {
	console.log('=== 测试按钮点击事件 ===')
	
	mockJobData.forEach((job, index) => {
		if (job.signup === true) {
			console.log(`岗位${index + 1}: ${job.title} - 已报名，点击无效`)
		} else {
			console.log(`岗位${index + 1}: ${job.title} - 未报名，可以点击报名`)
		}
	})
}

// 测试样式类名
function testButtonClasses() {
	console.log('=== 测试按钮样式类名 ===')
	
	mockJobData.forEach((job, index) => {
		const classes = ['apply-btn']
		if (job.signup === true) {
			classes.push('disabled')
		}
		
		console.log(`岗位${index + 1}: ${job.title}`)
		console.log(`  样式类名: ${classes.join(' ')}`)
		console.log('---')
	})
}

// 模拟组件渲染
function simulateComponentRender() {
	console.log('=== 模拟组件渲染 ===')
	
	mockJobData.forEach((job, index) => {
		const buttonHtml = `
			<view 
				class="apply-btn ${job.signup ? 'disabled' : ''}"
				@click.stop="${job.signup ? 'null' : 'applyJob(job, index)'}"
			>
				<text class="apply-text">${job.signup ? '已报名' : '一键报名'}</text>
			</view>
		`
		
		console.log(`岗位${index + 1}: ${job.title}`)
		console.log(`  渲染的HTML: ${buttonHtml.trim()}`)
		console.log('---')
	})
}

// 运行所有测试
function runAllTests() {
	testButtonState()
	testButtonClick()
	testButtonClasses()
	simulateComponentRender()
}

// 导出测试函数
export {
	testButtonState,
	testButtonClick,
	testButtonClasses,
	simulateComponentRender,
	runAllTests,
	mockJobData
}

// 如果直接运行此文件，执行所有测试
if (typeof window === 'undefined') {
	runAllTests()
}
